package cn.edu.just.firstjavaapp.l6;

public class HelloWorldAnonymousClasses {


    public static void sayHello(HelloWorld helloWorld) {
        helloWorld.greet();
        helloWorld.greetSomeone("李四");
    }

    public static void main(String[] args) {
        HelloWorld helloWorld = new ChineseHelloWorld();
        sayHello(helloWorld);

        sayHello(new HelloWorld() {
            @Override
            public void greet() {
                System.out.println("hello,Tom");
            }

            @Override
            public void greetSomeone(String someone) {
                System.out.println("hello,"+someone);
            }
        });
    }

}
class ChineseHelloWorld implements HelloWorld{

    @Override
    public void greet() {
        System.out.println("你好，张三!");
    }

    @Override
    public void greetSomeone(String someone) {
        System.out.println("你好,"+someone);

    }
}
interface HelloWorld {
    public void greet();
    public void greetSomeone(String someone);
}